package com.bg8loo.amateur.controller;


import com.bg8loo.amateur.pojo.Title;
import com.bg8loo.amateur.service.TitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;

@Controller
public class IndexPageController {

    @Autowired
    private TitleService titleService;

    //首页
    @GetMapping("/index")
    public String index(Model model) {
        return "Anchor/index";
    }

// 牛刀小试10道题A类
    @GetMapping("/test10")
    public String test10(Model model) {

//        int a=1/0;
        ArrayList<Title> titles = titleService.selectRoeaRand10();
        model.addAttribute("titles",titles);
//        for (Title t: titles) {
//            System.out.println(t.getAnswer());
//        }
//        model.addAttribute("hardWareList",hardWareList);
        return "Anchor/docs";
    }

//    牛刀小试10道题B类
    @GetMapping("/test10b")
    public String test10B(Model model) {
        ArrayList<Title> titles = titleService.selectRoebRand10();
        model.addAttribute("titles",titles);
//        System.out.println("访问B类题");
//        model.addAttribute("titles",titles);
//        for (Title t: titles) {
//            System.out.println(t);
//        }
//        model.addAttribute("hardWareList",hardWareList);
        return "Anchor/docsB";
    }

//    重定向到首页
    @RequestMapping("/")
    public String helloIndex(){
        return "forward:/index";
    }

    // 模拟考试A类
    @GetMapping("/study/A30")
    public String studyA30(Model model) {

//        int a=1/0;
        ArrayList<Title> titles = titleService.selectRoeaExam30();
        model.addAttribute("titles",titles);
//        for (Title t: titles) {
//            System.out.println(t.toString());
//        }
//      6*5=30题
        int[] titlesNum={0,1,2,3,4,5};
        model.addAttribute("titlesNum",titlesNum);
//        model.addAttribute("hardWareList",hardWareList);
        return "Anchor/examA";
    }

//    B类模拟考试
    @GetMapping("/study/B50")
    public String studyB50(Model model) {
        //        int a=1/0;
        ArrayList<Title> titles = titleService.selectRoebExam50();
        model.addAttribute("titles",titles);
//        System.out.println(titles.size());
//        for (Title t: titles) {
//            System.out.println(t.toString());
//        }
//         10*5=50题
        int[] titlesNum={0,1,2,3,4,5,6,7,8,9};
        model.addAttribute("titlesNum",titlesNum);
//        model.addAttribute("hardWareList",hardWareList);
        return "Anchor/examB";
    }

//    C类模拟考试
    @GetMapping("/study/C80")
    public String studyC80(Model model) {
        //        int a=1/0;
        ArrayList<Title> titles = titleService.selectRoecExam80();
        model.addAttribute("titles",titles);
//        System.out.println(titles.size());
//        for (Title t: titles) {
//            System.out.println(t.toString());
//        }

//        16*5=80题
        int[] titlesNum={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
        model.addAttribute("titlesNum",titlesNum);
//        model.addAttribute("hardWareList",hardWareList);
        return "Anchor/examC";
    }

//    错题本
    @GetMapping("/noteBook")
    public String noteBook(Model model) {
        ArrayList<Title> titles = titleService.selectRoeaRand10();
        model.addAttribute("titles",titles);
        return "Anchor/noteBook";
    }

}
